package vista;
import java.awt.BorderLayout;
import java.awt.event.ActionListener;
import java.util.Vector;
import bean.JTextFieldValidator;
import javabean.JPanelImagen;

import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JTextField;
import javax.swing.JTable;
import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;
import javax.swing.JOptionPane;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class vOrdenCompra extends javax.swing.JFrame {
	private JLabel lblnumerodeorden;
	private JLabel lblnumero;
	private JLabel lblcantidad;
	private JComboBox cmbproducto;
	private JLabel jLabel1;
	private JLabel lblcategoria;
	private JComboBox cmbcategoria;
	private JLabel lblProducto;
	private JScrollPane spdetalleorden;
	private JButton btnsalir;
	private JButton btncancelar;
	private JButton btnguardar;
	private JSeparator jSeparator1;
	private JLabel lblbs;
	private JTextField txttotal;
	private JLabel lblTotal;
	private JButton btnremover;
	private JButton btnincluir;
	private JTextFieldValidator txtcantidad;
	private JSeparator spProductos;
	private JTextFieldValidator txtnombre;
	private JTextFieldValidator txtcedula;
	private JLabel lblnombre;
	private JLabel lblcedula;
	private vDetalleOrdenMT modelo;
	private JTable DetalleOrden;
	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				vOrdenCompra inst = new vOrdenCompra();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public vOrdenCompra() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			this.setTitle("Orden Compra");
			getContentPane().setBackground(new java.awt.Color(255,255,255));
			getContentPane().setLayout(null);
			{
				lblnumerodeorden = new JLabel();
				getContentPane().add(lblnumerodeorden);
				lblnumerodeorden.setText("Numero De Orden ");
				lblnumerodeorden.setBounds(20, 26, 114, 16);
				lblnumerodeorden.setFont(new java.awt.Font("Segoe UI",1,12));
			}
			{
				lblnumero = new JLabel();
				getContentPane().add(lblnumero);
				lblnumero.setText("1");
				lblnumero.setBounds(152, 26, 10, 16);
				lblnumero.setFont(new java.awt.Font("Segoe UI",1,12));
			}
			{
				lblcedula = new JLabel();
				getContentPane().add(lblcedula);
				lblcedula.setText("Cedula :");
				lblcedula.setBounds(25, 78, 55, 16);
			}
			{
				lblnombre = new JLabel();
				getContentPane().add(lblnombre);
				lblnombre.setText("Nombre :");
				lblnombre.setBounds(206, 78, 60, 16);
			}
			{
				txtcedula = new JTextFieldValidator(JTextFieldValidator.SOLO_NUMEROS);
				getContentPane().add(txtcedula);
				txtcedula.setBounds(85, 75, 94, 23);
			}
			{
				txtnombre = new JTextFieldValidator(JTextFieldValidator.LETRAS_Y_ESPACIOS);
				getContentPane().add(txtnombre);
				txtnombre.setBounds(272, 75, 101, 23);
			}
			{
				spProductos = new JSeparator();
				getContentPane().add(spProductos);
				spProductos.setBounds(0, 121, 501, 10);
			}
			{
				lblProducto = new JLabel();
				getContentPane().add(lblProducto);
				lblProducto.setText("Producto");
				lblProducto.setBounds(192, 131, 85, 20);
				lblProducto.setFont(new java.awt.Font("Segoe UI",1,16));
			}
			{
				ComboBoxModel cmbcategoriaModel = 
					new DefaultComboBoxModel(
							new String[] { "Item One", "Item Two" });
				cmbcategoria = new JComboBox();
				getContentPane().add(cmbcategoria);
				cmbcategoria.setModel(cmbcategoriaModel);
				cmbcategoria.setBounds(85, 163, 107, 23);
			}
			{
				lblcategoria = new JLabel();
				getContentPane().add(lblcategoria);
				lblcategoria.setText("Categoria:");
				lblcategoria.setBounds(20, 166, 65, 16);
			}
			{
				jLabel1 = new JLabel();
				getContentPane().add(jLabel1);
				jLabel1.setText("Nombre :");
				jLabel1.setBounds(204, 166, 55, 16);
			}
			{
				ComboBoxModel cmbproductoModel = 
					new DefaultComboBoxModel(
							new String[] { "Item One", "Item Two" });
				cmbproducto = new JComboBox();
				getContentPane().add(cmbproducto);
				cmbproducto.setModel(cmbproductoModel);
				cmbproducto.setBounds(271, 163, 87, 23);
			}
			{
				lblcantidad = new JLabel();
				getContentPane().add(lblcantidad);
				lblcantidad.setText("Cantidad :");
				lblcantidad.setBounds(373, 166, 63, 16);
			}
			{
				txtcantidad = new JTextFieldValidator(JTextFieldValidator.SOLO_NUMEROS);
				getContentPane().add(txtcantidad);
				txtcantidad.setBounds(436, 163, 48, 23);
			}
			{
				spdetalleorden = new JScrollPane();
				getContentPane().add(spdetalleorden);
				spdetalleorden.setBounds(22, 207, 375, 136);
				{
					DetalleOrden = new JTable();
					spdetalleorden.setViewportView(DetalleOrden);
					modelo = new vDetalleOrdenMT();
					DetalleOrden.setModel(modelo);
				}
			}
			{
				btnincluir = new JButton();
				getContentPane().add(btnincluir);
				btnincluir.setText("Incluir");
				btnincluir.setBounds(403, 227, 87, 23);
			}
			{
				btnremover = new JButton();
				getContentPane().add(btnremover);
				btnremover.setText("Remover");
				btnremover.setBounds(403, 267, 87, 23);
			}
			{
				lblTotal = new JLabel();
				getContentPane().add(lblTotal);
				lblTotal.setText("Total : ");
				lblTotal.setBounds(342, 381, 41, 16);
			}
			{
				txttotal = new JTextField();
				getContentPane().add(txttotal);
				txttotal.setBounds(390, 378, 46, 23);
				txttotal.setEditable(false);
			}
			{
				lblbs = new JLabel();
				getContentPane().add(lblbs);
				lblbs.setText("Bs.");
				lblbs.setBounds(442, 381, 22, 16);
			}
			{
				jSeparator1 = new JSeparator();
				getContentPane().add(jSeparator1);
				jSeparator1.setBounds(0, 419, 501, 5);
			}
			{
				btnguardar = new JButton();
				getContentPane().add(btnguardar);
				btnguardar.setText("Guardar");
				btnguardar.setBounds(34, 445, 84, 23);
			}
			{
				btncancelar = new JButton();
				getContentPane().add(btncancelar);
				btncancelar.setText("Cancelar");
				btncancelar.setBounds(134, 445, 89, 23);
			}
			{
				btnsalir = new JButton();
				getContentPane().add(btnsalir);
				btnsalir.setText("Salir");
				btnsalir.setBounds(383, 445, 79, 23);
			}
			pack();
			this.setSize(517, 534);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
		
	}
	public void setcantidad(String valor)
	{
		txtcantidad.setText(valor);
	}
	public String getproducto()
	{
	return cmbproducto.getSelectedItem().toString();
	}
	public String getcategoria()
	{
		return cmbcategoria.getSelectedItem().toString();
	
	}
	public int getNumeroorden()
	{
		return Integer.parseInt(lblnumero.getText());
	}
	public void setNumeroorden(int Numero)
	{
		Numero=Numero+1;
		lblnumero.setText(String.valueOf(Numero));
	}
	public String getcedula()
	{
		return txtcedula.getText();
	}
	public String getnombre()
	{
		return  txtnombre.getText();
	}
	public String gettotal()
	{
		return txttotal.getText();
	}
	public void setTotal(double acumulador)
	{
	    txttotal.setText(String.valueOf(acumulador));
	}
	public String getcantidad()
	{
		return txtcantidad.getText();
	}
	
	public void addListener(ActionListener actionListener)
	{
		btnguardar.addActionListener(actionListener);
		btncancelar.addActionListener(actionListener);
		btnsalir.addActionListener(actionListener);
		cmbcategoria.addActionListener(actionListener);
		btnincluir.addActionListener(actionListener);
		btnremover.addActionListener(actionListener);
    }
	
	public void Mensaje(String mensaje) 
	{
		JOptionPane.showMessageDialog(this, mensaje);
	}
	
	public void Limpiar()
	{
		txtnombre.setText("");
		txtcedula.setText("");
		txttotal.setText("");
		txtcantidad.setText("");		
	}
	public JComboBox getcombo()
	{
		return cmbcategoria;
	}
	public void CargarComboCategoria(Vector<String> vector)
	{
		ComboBoxModel cmbcategoriamodel = new DefaultComboBoxModel(vector);
		cmbcategoria.setModel(cmbcategoriamodel);
	}
	
	public void CargarComboProducto(Vector<String> vector)
	{
		ComboBoxModel cmbproductomodel = new DefaultComboBoxModel(vector);
		cmbproducto.setModel(cmbproductomodel);
	}
	public vDetalleOrdenMT getmodelo()
	{
		return modelo;
	}
	
	public int Posicion()
	{
		return DetalleOrden.getSelectedRow();
	}
}
